DEFINE VARIABLE tax AS CHARACTER FORMAT "X(4)".
DEFINE VARIABLE vend AS CHARACTER FORMAT "X(8)".
DEFINE VARIABLE rate AS DECIMAL.

FOR EACH ptp_det WHERE can-do("P,M",ptp_pm_code) AND ptp_part BEGINS "914" exclusive,
    EACH pt_mstr WHERE pt_part = ptp_part NO-LOCK:
    IF pt_part_type <> "RM-C" AND pt_part_type <> "FG-C" THEN DO:
       
       tax = "".
       vend = "".
       FOR EACH pc_mstr NO-LOCK WHERE pc_part = ptp_part BREAK BY pc_part BY pc_start DESC:
           IF FIRST-OF (pc_part) THEN DO:
              FIND FIRST ad_mstr WHERE ad_addr = pc_list NO-LOCK NO-ERROR.
              IF AVAILABLE ad_mstr THEN DO:
                 tax = ad_tax_usage.
                 vend = ad_addr.
              END.  
              ELSE DO:
                 tax = "".
                 vend = "".
              END.
                 
           END.
       END.
       rate = DECIMAL(SUBSTRING(tax,2,3)) / 100.
          DISP ptp_site ptp_part ptp_pm_code rate tax vend ptp__dec01 ptp__dec02 pt_desc1 pt_status pt_part_type
          WITH STREAM-IO WIDTH 200.
/*        IF abs(rate - ptp__dec02) > 0.005 AND (ptp__dec02 = 0.17 OR ptp__dec02 = 0) THEN DO:                      */
/*           ASSIGN ptp__dec02 = rate.                                                                              */
/*           DISP ptp_site ptp_part ptp_pm_code rate tax vend ptp__dec01 ptp__dec02 pt_desc1 pt_status pt_part_type */
/*           WITH STREAM-IO WIDTH 200.                                                                              */
/*        END.                                                                                                      */
    END.
END.
